<?php
#### Roshan's Ajax dropdown code with php
#### Copyright reserved to Roshan Bhattarai - nepaliboy007@yahoo.com
#### if you have any problem contact me at http://roshanbh.com.np
#### fell free to visit my blog http://php-ajax-guru.blogspot.com
?>

<?php $province=$_GET['province'];
$link = mysql_connect('localhost', 'root', ''); //changet the configuration in required
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
mysql_select_db('project192');
$query="select city from philippines where province=\"$province\" ORDER BY city ASC";
$result=mysql_query($query);
?>
<select name="city" id="city">
<option></option>
<?php while($row=mysql_fetch_array($result)) { ?>
<?php if($_GET['city'] == $row['city'])
	{
		?><option value="<?php echo $row['city']?>" selected="selected"><?php echo $row['city']?></option><?php
	}
	
	else
	{
		?><option value="<?php echo $row['city']?>"><?php echo $row['city']?></option><?php
	}

?>

<?php } ?>
</select>
